/*****************************************************************************
 * dict.h: Public interface for basic dictionary
 *****************************************************************************
 * Copyright (C) 2012
 *
 * Authors: Dan Larkin <danielhlarkin@gmail.com>
 *          Yonatan Naamad <cached@gmail.com>
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *****************************************************************************/

#ifndef CPM_DICT
#define CPM_DICT

#include <stdint.h>
#include <stdlib.h>

typedef struct cpm_dict_node
{
    struct cpm_dict_node *parent;
    struct cpm_dict_node *left;
    struct cpm_dict_node *right;
    void *element;
} cpm_dict_node;

typedef struct cpm_dict
{
    int32_t key_len;
    cpm_dict_node *root;
} cpm_dict;

cpm_dict* cpm_dict_init( int32_t key_len );
void cpm_dict_insert( cpm_dict *dict, void *element );
void cpm_dict_delete( cpm_dict *dict, cpm_dict_node *node );
cpm_dict_node* cpm_dict_lookup( cpm_dict *dict, void *key );

#endif
